package com.lqk.facade.factory.simplefactory.pizzastore.order;

import com.lqk.facade.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.lqk.facade.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.lqk.facade.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * @author lqk
 * @date 2021/11/30 20:26
 */
// 简单工厂类

/**
 * 简单工厂模式也叫静态工厂模式
 */
public class SimpleFactory {
    // 根据 orderType 返回对应的 Pizza 对象
    public Pizza createPizza(String orderType){
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if ("greek".equals(orderType)){
            pizza = new GreekPizza();
            pizza.setName("希腊风味披萨");
        }else if ("cheese".equals(orderType)){
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }else if ("pepper".equals(orderType)){
            pizza = new CheesePizza();
            pizza.setName("胡椒披萨");
        }

        return pizza;
    }

    // 根据 orderType 返回对应的 Pizza 对象
    public static Pizza createPizza2(String orderType){
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if ("greek".equals(orderType)){
            pizza = new GreekPizza();
            pizza.setName("希腊风味披萨");
        }else if ("cheese".equals(orderType)){
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }else if ("pepper".equals(orderType)){
            pizza = new CheesePizza();
            pizza.setName("胡椒披萨");
        }

        return pizza;
    }
}
